﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace The_LarX
{
    public class WebPageInterpreter
    {
        public Dictionary<string, Type> SupportedMethods = new Dictionary<string, Type>();

        public void Interpet(LarWebPage page)
        {
            List<WebPageMethodCalls> Calls = page.DrawMethod.MethodCalls;
            for (int i = 0; i < Calls.Count; i++)
            {
                if (SupportedMethods.ContainsKey(Calls[i].Name))
                {
                    Type type = SupportedMethods[Calls[i].Name];
                    InterpreterMethodCollection col = (InterpreterMethodCollection)System.Activator.CreateInstance(type);
                    InterpreterArguments arguments = new InterpreterArguments(page, Calls[i].Arguments);
                    col.CallCorrectMethod(arguments);
                }
            }
        }
    }
}
